#ifndef MOTO_CAN_H
#define MOTO_CAN_H
typedef struct
{
	struct
	{
		UINT16 u16Rx18xLostCnt;
		UINT16 u16Rx28xLostCnt;
		UINT8 fRx18xLost:1;
		UINT8 fRx28xLost:1;
		UINT8 fRx18xUpdate:1;
		UINT8 fRx28xUpdate:1;
	}stRxCtrl;
	union
	{
		UINT8 Bytes[8];
		struct
		{
			UINT16 u16SpeedRef;
			/*
			bit0:电源使能
			bit1:接触器使能
			bit2:刹车使能
			bit3:前进
			bit4:后退
			*/
			UINT8 fPowerEn:1;
			UINT8 fRelayEn:1;
			UINT8 fBrakeEn:1;
			UINT8 fForward:1;
			UINT8 fBackward:1;
			UINT8 u8Byte2NC:3;

			UINT8 u8Byte3NC1:4;
			UINT8 fReleaseBrake:1;
			UINT8 u8Byte3NC2:3;

			UINT8 BytesNC[4];
		}bit;
	}unTx20x;
	union
	{
		UINT8 Bytes[8];
		struct
		{
			UINT16 u16SpeedFbk;
			UINT8 BytesNC[5];
			UINT8 u8PhaseCurrent;
		}bit;
	}unRx18x;
	union
	{
		UINT8 Bytes[8];
		struct
		{
			UINT8 u8ErrCode;
			UINT8 Byte1NC;
			UINT8 u8MotoTemp;
			INT8 s8CtrlTemp;
			UINT8 u8BDI;
			INT8 s8AvrCurrent;
			UINT16 u16BattVoltage;
		}bit;
	}unRx28x;
}structWalkMotoCan;
typedef struct
{
	struct
	{
		UINT16 u16Rx18xLostCnt;
		UINT16 u16Rx28xLostCnt;
		UINT8 fRx18xLost:1;
		UINT8 fRx28xLost:1;
		UINT8 fRx18xUpdate:1;
		UINT8 fRx28xUpdate:1;
	}stRxCtrl;
	union
	{
		UINT8 Bytes[8];
		struct
		{
			UINT16 u16AngleRef;
			/*
			bit0:电源使能
			bit1:接触器使能
			bit2:刹车使能
			bit3:前进
			bit4:后退
			*/
			UINT8 fPowerEn:1;
			UINT8 fRelayEn:1;
			UINT8 fBrakeEn:1;
			UINT8 fForward:1;
			UINT8 fBackward:1;
			UINT8 u8Byte2NC:3;

			UINT8 BytesNC[4];
		}bit;
	}unTx20x;
	union
	{
		UINT8 Bytes[8];
		struct
		{
			UINT16 u16AngleFbk;
			UINT16 u16Speed;
			UINT8 BytesNC[3];
			UINT8 u8PhaseCurrent;
		}bit;
	}unRx18x;
	union
	{
		UINT8 Bytes[8];
		struct
		{
			UINT8 u8ErrCode;
			UINT8 u8Byte1NC;
			UINT8 u8MotoTemp;
			INT8 s8CtrlTemp;
			UINT8 u8BDI;
			INT8 s8AvrCurrent;
			UINT16 u16BattVoltage;
		}bit;
	}unRx28x;
}structStreerMotoCan;
typedef struct
{
	struct
	{
		UINT16 u16Rx28ALostCnt;
		UINT8 fRx28ALost:1;
		UINT8 fRx28AUpdate:1;
	}stRxCtrl;
	union
	{
		UINT8 Bytes[8];
		struct
		{
			UINT16 U16SpeedRef;
			
			UINT8 u8PowerEn:1;
			UINT8 u8RelayEn:1;
			UINT8 u8Byte2NC:6;

			UINT8 Bytes[5];
		}bit;
	}unTx20A;
	union
	{
		UINT8 Bytes[8];
		struct
		{
			UINT8 u8ErrCode;
			UINT8 BytesNc[2];

			INT8 s8CtrlTemp;
			UINT8 u8BDI;
			INT8 s8AvrCurrent;
			UINT16 u16BattVoltage;
		}bit;
	}unRx28A;
}structPumpMotoCan;
typedef enum
{
	WalkMoto2=0,
	WalkMoto4,
	WalkMoto6,
	WalkMoto8,
	WalkMotoLen
}enumWalkMoto;
typedef enum
{
	StreerMoto3=0,
	StreerMoto5,
	StreerMoto7,
	StreerMoto9,
	StreerMotoLen
}enumStreerMoto;

extern structWalkMotoCan stWalkMotoCan[WalkMotoLen];
extern structStreerMotoCan stStreerMotoCan[StreerMotoLen];
extern structPumpMotoCan stPumpMotoCan;


extern void vWalkMoto18xRxCallback(UINT16 u16_id_hi,UINT16 u16_id_lo,UINT8 u8_length,UINT8 *pData);//200us中断回调
extern void vWalkMoto28xRxCallback(UINT16 u16_id_hi,UINT16 u16_id_lo,UINT8 u8_length,UINT8 *pData);//200us中断回调
extern void vStreerMoto18xRxCallback(UINT16 u16_id_hi,UINT16 u16_id_lo,UINT8 u8_length,UINT8 *pData);
extern void vStreerMoto28xRxCallback(UINT16 u16_id_hi,UINT16 u16_id_lo,UINT8 u8_length,UINT8 *pData);
extern void vPumpMoto28A_RxCallback(UINT16 u16_id_hi,UINT16 u16_id_lo,UINT8 u8_length,UINT8 *pData);
//
extern void vWalkMotoRx(void);
extern void vWalkMotoTx(void);
extern void vStreerMotoRx(void);
extern void vStreerMotoTx(void);
extern void vPumpMotoRx(void);
extern void vPumpMotoTx(void);


#endif
